﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace WpfApp4
{
    public class StackPanelRegionAdapter : RegionAdapterBase<StackPanel>
    {
        public StackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory)
        {

        }

        protected override void Adapt(IRegion region, StackPanel regionTarget)
        {
            region.Views.CollectionChanged += (sender, args) =>
            {
                foreach (FrameworkElement ele in args.NewItems)
                {
                    regionTarget.Children.Add(ele);
                }

            };
        }

        protected override IRegion CreateRegion()
        {
           return new AllActiveRegion();
        }
    }
}
